#import "layer_box2d_render.h"

@implementation LayerBox2dRender

- (id)initLayerBox2dRender
{
	if ((self = [super init]))
	{
		debugDraw_ = new GLESDebugDraw(CMgrGamePhysics::Ratio());
		CMgrGamePhysics::World()->SetDebugDraw(debugDraw_);
		debugDraw_->SetFlags(b2DebugDraw::e_shapeBit);
	}
	return self;
}

- (void)dealloc
{
	if (NULL != debugDraw_)
	{
		delete debugDraw_;
		debugDraw_ = NULL;
	}
	[super dealloc];
}

- (void)draw
{
	glDisable(GL_TEXTURE_2D);
	glDisableClientState(GL_TEXTURE_COORD_ARRAY);
	glDisableClientState(GL_COLOR_ARRAY);

	if (NULL != CMgrGamePhysics::Instance())
	{
		CMgrGamePhysics::World()->DrawDebugData();
	}

	glEnable(GL_TEXTURE_2D);
	glEnableClientState(GL_TEXTURE_COORD_ARRAY);
	glEnableClientState(GL_COLOR_ARRAY);
}

@end